package com.hk.commons.vo;

import com.hk.commons.StringHelper;

import java.math.BigDecimal;

/**
 * 统计信息
 * 
 * @author jeff
 *
 */

public class StatisticsMsg implements java.io.Serializable,  Comparable<StatisticsMsg>{

	/**
	 * 
	 */
	private static final long serialVersionUID = -8745832007157072617L;

	private Long userId;

	private Integer orgId;

	private Integer orgParentID;

	/**
	 * 组织结构类别 1 : 集团 2 : 公司 3 : 部门 4 : 职务
	 * */
	private Integer orgType;

	/** 助记码 */
	private String code;

	/** 创建人 */
	private String creator;

	/** 节点名称 */
	private String name;

	/** 顶级节点名称 */
	private String topName;

	/** 次级节点名称 */
	private String secondName;

	/** 显示节点名称 */
	private String showName;

	/** 是否是部门负责人 **/
	private String flag01;

	private String flag02;

	/** 用户名 */
	private String userName;

	//父节点名称
	private Integer parentNodeId;


	/**
	 * 部门理财师总数
	 */
	private Integer financialPlannerNum = 0;

	/**
	 * 使用 app 人数
	 */
	private Integer financialAppNum = 0;

	/** 绑卡人数 */
	private Integer tiedCardUserAccount = 0 ;

	/** 预约记录数关联用户 */
	private Integer relationUserAccount = 0;

	/**
	 * 预约记录数预约记录数
	 * 
	 * */
	private Integer bespeakOrderNum = 0;

	/** 预约记录数预约记录总金额 */
	private BigDecimal bespeakOrderAmount = new BigDecimal("0.00");

	/** 付款订单记录数 */
	private Integer payOrderNum = 0;

	/** 付款订单总金额 */
	private BigDecimal payOrderAmount = new BigDecimal("0.00");

	/** 折标付款订单总金额 */
	private BigDecimal niggerAmmount = new BigDecimal("0.00");

	private Long startTime;

	private Long endTime;

	private Long prodId;


	private Long parId;

	private Integer sequence;

	public StatisticsMsg(String topName, String secondName, String showName,
			String code, Integer sequence) {
		this.topName = topName;
		this.secondName = secondName;
		this.showName = showName;
		this.code = code;
		this.sequence = sequence;
	}

	public StatisticsMsg() {
	}

	public Long getParId() {
		return parId;
	}

	public void setParId(Long parId) {
		this.parId = parId;
	}

	public Integer getOrgType() {
		return orgType;
	}

	public void setOrgType(Integer orgType) {
		this.orgType = orgType;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getCreator() {
		return creator;
	}

	public void setCreator(String creator) {
		this.creator = creator;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getFlag01() {
		return flag01;
	}

	public void setFlag01(String flag01) {
		this.flag01 = flag01;
	}

	public String getFlag02() {
		return flag02;
	}

	public void setFlag02(String flag02) {
		this.flag02 = flag02;
	}

	public Integer getOrgId() {
		return orgId;
	}

	public void setOrgId(Integer orgId) {
		this.orgId = orgId;
	}

	public Integer getOrgParentID() {
		return orgParentID;
	}

	public void setOrgParentID(Integer orgParentID) {
		this.orgParentID = orgParentID;
	}

	public Integer getTiedCardUserAccount() {
		return tiedCardUserAccount;
	}

	public void setTiedCardUserAccount(Integer tiedCardUserAccount) {
		this.tiedCardUserAccount = tiedCardUserAccount;
	}

	public Integer getRelationUserAccount() {
		return relationUserAccount;
	}

	public void setRelationUserAccount(Integer relationUserAccount) {
		this.relationUserAccount = relationUserAccount;
	}

	public Integer getBespeakOrderNum() {
		return bespeakOrderNum;
	}

	public void setBespeakOrderNum(Integer bespeakOrderNum) {
		this.bespeakOrderNum = bespeakOrderNum;
	}

	public BigDecimal getBespeakOrderAmount() {
		return bespeakOrderAmount;
	}

	public void setBespeakOrderAmount(BigDecimal bespeakOrderAmount) {
		this.bespeakOrderAmount = bespeakOrderAmount;
	}

	public Integer getPayOrderNum() {
		return payOrderNum;
	}

	public Long getStartTime() {
		return startTime;
	}

	public void setStartTime(Long startTime) {
		this.startTime = startTime;
	}

	public Long getEndTime() {
		return endTime;
	}

	public void setEndTime(Long endTime) {
		this.endTime = endTime;
	}

	public void setPayOrderNum(Integer payOrderNum) {
		this.payOrderNum = payOrderNum;
	}

	public BigDecimal getPayOrderAmount() {
		return payOrderAmount;
	}

	public void setPayOrderAmount(BigDecimal payOrderAmount) {
		this.payOrderAmount = payOrderAmount;
	}

	/**
	 * 绑卡人数增加制定的数目
	 * 
	 * @param num
	 */
	public void plusTiedCardUserAccount(Integer num) {
		if (this.tiedCardUserAccount == null) {
			this.tiedCardUserAccount = num;
		} else {
			this.tiedCardUserAccount += num;
		}
	}

	/**
	 * 邀请人数增加制定的数目
	 * 
	 * @param num
	 */
	public void plusRelationUserAccount(Integer num) {
		if (this.relationUserAccount == null) {
			this.relationUserAccount = num;
		} else {
			this.relationUserAccount += num;
		}
	}

	/**
	 * 预约记录数目
	 * 
	 * @param num
	 */
	public void plusBespeakOrderNum(Integer num) {
		if (this.bespeakOrderNum == null) {
			this.bespeakOrderNum = num;
		} else {
			this.bespeakOrderNum += num;
		}
	}

	/**
	 * 预约记录总金额
	 * 
	 * @param
	 */
	public void plusBespeakOrderAmount(BigDecimal amount) {
		if (amount != null) {
			if (this.bespeakOrderAmount == null) {
				this.bespeakOrderAmount = amount;
			} else {
				this.bespeakOrderAmount = this.bespeakOrderAmount.add(amount);
			}
		}
	}

	/**
	 * 付款记录数目
	 * 
	 * @param num
	 */
	public void plusPayOrderNum(Integer num) {
		if (this.payOrderNum == null) {
			this.payOrderNum = num;
		} else {
			this.payOrderNum += num;
		}
	}

	/**
	 * 预约记录总金额
	 * 
	 * @param
	 */
	public void plusPayOrderAmount(BigDecimal amount) {
		if (amount != null) {
			if (this.payOrderAmount == null) {
				this.payOrderAmount = amount;
			} else {
				this.payOrderAmount = this.payOrderAmount.add(amount);
			}
		}
	}

	public Integer getFinancialPlannerNum() {
		return financialPlannerNum;
	}

	public void setFinancialPlannerNum(Integer financialPlannerNum) {
		this.financialPlannerNum = financialPlannerNum;
	}

	public String getTopName() {
		return topName;
	}

	public void setTopName(String topName) {
		this.topName = topName;
	}

	public String getSecondName() {
		return secondName;
	}

	public void setSecondName(String secondName) {
		this.secondName = secondName;
	}

	public String getShowName() {
		return showName;
	}

	public void setShowName(String showName) {
		this.showName = showName;
	}

	public Integer getSequence() {
		return sequence;
	}

	public void setSequence(Integer sequence) {
		this.sequence = sequence;
	}

	public Long getProdId() {
		return prodId;
	}

	public void setProdId(Long prodId) {
		this.prodId = prodId;
	}

	public BigDecimal getNiggerAmmount() {
		return niggerAmmount;
	}

	public void setNiggerAmmount(BigDecimal niggerAmmount) {
		this.niggerAmmount = niggerAmmount;
	}

	public Integer getParentNodeId() {
		return parentNodeId;
	}

	public void setParentNodeId(Integer parentNodeId) {
		this.parentNodeId = parentNodeId;
	}

	@Override
	public int compareTo(StatisticsMsg o) {

		Integer compareResult = 0;
		compareResult = compareName(this, o);

		if(compareResult != 0){
			return compareResult;
		}

		//02 对比父节点
		compareResult = compareParId(this, o);
		return 0;
	}

	public int compareName(StatisticsMsg x, StatisticsMsg y){

		//System.out.println("compareSequence : " + " x.name = " + x.getName() + " sequence = " +  x.getSequence() + y.getName() + " sequence = " + y.getSequence() );
		if(x.getShowName().equals("华康财富")){
			return 1;
		}else if(y.getShowName().equals("华康财富")){
			return -1;
		}


		else if(StringHelper.isEmpty(x.getShowName()) && StringHelper.isEmpty(y.getShowName())){
			return  0;
		}else if(StringHelper.isEmpty(x.getShowName()) && !StringHelper.isEmpty(y.getShowName())){
			return 1;
		}else if(!StringHelper.isEmpty(x.getShowName()) && StringHelper.isEmpty(y.getShowName())){
			return -1;
		}else{
			return x.getShowName().compareTo(y.getShowName()) * -1;
		}
	}

	public Integer getFinancialAppNum() {
		return financialAppNum;
	}

	public void setFinancialAppNum(Integer financialAppNum) {
		this.financialAppNum = financialAppNum;
	}

	public int compareParId(StatisticsMsg x, StatisticsMsg y){
		return x.getParentNodeId().compareTo(y.getParentNodeId());
	}
}
